from functools import lru_cache

from pydantic import BaseSettings


# dotenv_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), '.fastenv')
# if os.path.exists(dotenv_path):
#     load_dotenv(dotenv_path, override=True)  # override=True: 覆写已存在的变量
#
# dotenv_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), '.env')
# if os.path.exists(dotenv_path):
#     load_dotenv(dotenv_path, override=True)  # override=True: 覆写已存在的变量


class Settings(BaseSettings):
    app_name: str = "Awesome API"
    SQLALCHEMY_DATABASE_URI: str
    SQLALCHEMY_DATABASE_URI_2: str

    class Config:
        env_file = ".env"


@lru_cache()
def get_settings():
    return Settings()

